<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'detail';
$return=array();
$return['diy']=$this->plugin_setting('diy');
if($_RQ['op']=='detail'){
	if(!$_RQ['id']){
	exi('订单不存在，请重新选择','error');
	}
	$order=pdo_get('jy_tour_order',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	$spot=pdo_get('jy_tour_spot',array('id'=>$order['spot_id'],'uniacid'=>$_SESSION['uniacid']));
	if($order['merchid']){
		$merch=pdo_get('jy_tour_merch',array('id'=>$order['merchid'],'uniacid'=>$_SESSION['uniacid']));
	}else{
		$merch=array();
	}
	$way=pdo_get('jy_tour_way',array('id'=>$order['way_id'],'uniacid'=>$_SESSION['uniacid']));
	$ticket=pdo_get('jy_tour_spot_ticket',array('id'=>$order['ticket_id'],'uniacid'=>$_SESSION['uniacid']));
	$order['createtime']=date('Y-m-d H:i:s', $order['createtime']);
	$order['ticket']=$ticket;
	$order['way']=$way;
	$order['merch']=$merch;
	$order['spot']=$spot;
	//用户信息
	$member=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$order['mid']));
	//定义订单状态名称
	if($order['status']==0){
		$order['statustitle']='订单待支付';
		$order['statusdesc']='超时未支付，订单将自动取消';
	}elseif($order['status']==1 && !$order['refundstate']){
		$order['statustitle']='买家已付款';
		$order['statusdesc']='请您留意订单进度';
	}elseif($order['status']==2 && !$order['refundstate']){
		$order['statustitle']='订单处理中';
		$order['statusdesc']='请您留意订单进度';
	}elseif($order['status']==3 && !$order['refundstate']){
		$order['statustitle']='订单已完成';
		$order['statusdesc']='';
	}elseif($order['status']==4 && !$order['refundstate']){
		$order['statustitle']='订单已关闭';
		$order['statusdesc']='';
	}elseif($order['refundstate']>0 && $order['status']==1){
		$order['statustitle']='申请退款中';
		$order['statusdesc']='请您留意退款进度';
	}elseif($order['refundstate']>0 && $order['status']>1){
		$order['statustitle']='申请售后中';
		$order['statusdesc']='请您留意售后进度';
	}
	$return['order']=$order;
	$return['member']=$member;
	$return['selfnumberurl']=custom_url('jy_tour/merch.verifydetail//id='.$order['id'].'&ordersn='.$order['ordersn'],true);
	//小程序二维码：
	$url='/jy_tour/merch/verifydetail/index?id='.$order['id'].'&ordersn='.$order['ordersn'];
	$pid='verifyid'.$order['id'].'c'.$order['ordersn'];
	$return['appcode'] = model('jy_weishop/model')->get_wxappewm($url,$pid);
	exi($return);
}